1. Field of the Invention
The present invention relates to a method for data compression and restoration, an apparatus and a method for sort-merging, and storage media therefor.
2. Description of the Related Art
As a method for compressing data consisting of numeric characters, alphabetic characters, chinese characters and the like, a dictionary type coding system is known. The dictionary type coding system comprises a dictionary that collects coded data corresponding to different character strings each created in a predetermined form. The system uses the dictionary to compress data having the character strings by the registered codes corresponding to the strings stored in the dictionary. The system further compresses data having the same character in series with the use of control characters. This system is required to register character strings each having a predetermined form and to store the strings with corresponding codes in advance. Namely, time and labour are required for making the dictionary. In addition, any character strings that are not registered cannot be compressed. Furthermore, the system requires time for data compression when sequentially retrieving each of the registered characters.
Therefore, a method of data record compression, as disclosed in the Japanese patent publication No. 7-239771, was proposed that dispenses with creation of the dictionary. According to this method, data records in a file, each record having a plurality of fields, can be compressed when fields having the same value exist in the consecutive data records in the data file.
The above method of data record compression vertically compresses a part in which a predetermined number of the same characters consecutively appear in the same field location in the two consecutive data records, and horizontally compresses a part in which a predetermined number of the same characters consecutively appear in the vertically compressed records.
By the way, in general, a sort-merge process is executed when sorting a large amount of data records. The sort-merge process has the steps of, reading a plurality of data records stored in an input file in a storage unit one by one into an input buffer in a memory, transferring the data records stored in the input buffer to a working area in the memory until the working area becomes full, transferring a group of data records transferred to the working area to a temporary buffer after sorting the group of the data records, and transferring the group of data records from the temporary buffer to a temporary file in the storage unit. The sort-merge process repeats the above series of steps for all of the data records to be sorted, then executes the steps of transferring the group of data records having been sorted and stored in the temporary file to each individual temporary buffer in the memory, transferring the data stored in the temporary buffer to a work area in the memory, generating a string of records by merging, and outputs the string of records to an output file.
However, the method of data record compression disclosed in the Japanese patent publication No. 7-239771 can compress two consecutive data records but cannot compress more than that at one time. Therefore the method is inefficient.
On the other hand, the sort-merge process according to the prior art requires a long time for data transmission between the temporary file in the external storage unit and the temporary buffer in the main memory when a large volume of data records are sorted, and the size of data to be stored in the external storage is increased. Thus, the sort-merge processing time is increased and the disc space in the external storage unit cannot be ensured.